<div class="span6">
    <form id="frm_pass" method="post" action="<?php echo site_url("pass/change"); ?>" class="form-horizontal">
        <fieldset>
            <!-- Form Name -->
            <legend>Change Password</legend>
        </fieldset>
        <div id="alert" class="alert alert-error">
            <strong>Error </strong>
            Passwords missmatch
        </div>

        <div id="success" class="alert alert-success">
            <strong>Info </strong>
            Your Password has been successfully changed
        </div>

        <div id="error" class="alert alert-error">
            <strong>Error </strong>
            Current Password incorrect !
        </div>
        <!-- Text input-->
        <div class="control-group">
            <label class="control-label" for="id_current">Current Password</label>
            <div class="controls">
                <input id="id_current" name="current" type="password" placeholder="Current Password" class="input-large" required="">
            </div>
        </div>

        <div class="control-group">
            <label class="control-label" for="id_new">New Password</label>
            <div class="controls">
                <input onkeyup="verif();" name="new" id="id_new" type="password" placeholder="New Password" class="input-large" required="">
            </div>
        </div>

        <div class="control-group">
            <label class="control-label" for="id_confirm">Confirm new Password</label>
            <div class="controls">
                <input onkeyup="verif()" id="id_confirm" name="confirm" type="password" placeholder="Confirm New Password" class="input-large" required="">
                <img id="img_conform" src="<?php echo img_url() . "conform.png"; ?>"/>
            </div>
        </div>

        <!-- Button -->
        <div class="control-group">
            <label class="control-label" for=""></label>
            <div class="controls">
                <input onclick="return verifBeforeSubmit()" type="submit" name="gochange" class="btn btn-primary" value="Change Now"/>
            </div>
        </div>
    </form>
</div>
<script>
                    hideAlerts();
                    function hideAlerts() {
                        $("#img_conform").hide();
                        $("#alert").hide();
                        $("#success").hide();
                        $("#error").hide();
                    }
                    function verif() {
                        // alert($("#id_new").val() + "   vs   "+$("#id_confirm").val())
                        if ($("#id_new").val() === "") return;
                        if ($("#id_new").val() === $("#id_confirm").val()) {
                            $("#img_conform").show();
                        } else {
                            $("#img_conform").hide();
                        }
                    }

                    function verifBeforeSubmit() {
                        hideAlerts();
                        url = "<?php echo site_url("pass/change"); ?>";
                        if ($("#id_new").val() !== $("#id_confirm").val()) {
                            $("#alert").show();
                            return false;
                        } else {
                            $.ajax({
                                type: "POST",
                                url: url,
                                async: true,
                                timeout: 15000, // 30 secondes
                                data: $("#frm_pass").serialize(), // serializes the form's elements.
                                success: function(data) {
                                    //alert(data);
                                    if (data == 1) {
                                        $("#success").show();
                                    } else if (data == 0) {
                                        $("#error").show();
                                    } else {
                                        $("#error").show();
                                    }
                                },
                                complete: function(a) {
                                    // $("#error").show();
                                }
                            });
                        }
                        return false;
                    }
</script>